class MyRunnable implements Runnable{
    @Override
    public void run() {
        while ( true){
            System.out.println("Thread is running");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
public class Demo2 {
    public static void main(String[] args) {
        MyRunnable t = new MyRunnable();
        Thread thread = new Thread(t);
        thread.start();
        while (true){
            System.out.println("Main thread is running");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
